export default{
  namespaced:true,
  state:()=>({
    address:JSON.parse(uni.getStorageSync('address')||'{}'),
    token:'',
    userInfo:JSON.parse(uni.getStorageSync('userInfo')||'{}')
  }),
  mutations:{
    saveAddress(state,val){
      state.address=val
      this.commit('m_address/saveToAddress')
    },
    saveToAddress(state){
      uni.setStorageSync('address',JSON.stringify(state.address))
    },
    saveUser(state,user){
      state.userInfo=user
      this.commit('m_address/saveToUser')
    },
    saveToUser(state){
      uni.setStorageSync('userInfo',JSON.stringify(state.userInfo))
    }
  },
  getters:{
    detail(state){
      if(state.address.provinceName=='')return ''
      return state.address.provinceName+state.address.cityName+state.address.countyName+state.address.detailInfo
    }
  }
}